﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web;
using System.Data;

public partial class ConfExpertMaster : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Sessions.CurrentMember == null || Sessions.CurrentMember.IsNull())
        {
            Sessions.GlobalMessage = Strings.Yetkisiz;
            base.Response.Redirect("~/Default.aspx");
        }

        //lblHeader.EncodeHtml = false;
        string name = Sessions.CurrentMember.Name;
        name = Utils.ToProperCase(name);
        lblHeader.InnerText = String.Format("Dear {0}", name );


        btnMyOrders.Visible = btnMissing.Visible = (Sessions.CurrentMember.CustomerId == 22);
        
    }

    protected void btnMyReservations_Click(object sender, EventArgs e)
    {
        Response.Redirect("MyReservations.aspx");
    }

    protected void btnStock_Click(object sender, EventArgs e)
    {
        Response.Redirect("Stock.aspx");
    }
    protected void btnMissing_Click(object sender, EventArgs e)
    {
        Response.Redirect("Du4Missing.aspx");
    }

    protected void btnOrders_Click(object sender, EventArgs e)
    {
        Response.Redirect("MyOrders.aspx");
    }

    protected void btnExport_Click(object sender, EventArgs e)
    {
        Utils.DumpExcel(TableToExport);    
    }
    
    public DataTable TableToExport = null;
   

    protected void btnLogout_Click(object sender, EventArgs e)
    {
        Session.Clear();
        Sessions.CurrentMember = new Member();
        Sessions.GlobalMessage = "";
        Response.Redirect("~/Default.aspx");
    }

    protected void btnOK_Click(object sender, EventArgs e)
    {
        pnlResult.Visible = false;
        pnlLogin.Visible = true;
        popupPass.ShowOnPageLoad = false;
        Response.Redirect("~/Members/Stock.aspx");
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        pnlResult.Visible = true;
        pnlLogin.Visible = false;

        if (DataAccess.ChangePassword(Sessions.CurrentMember.CustomerId, txtCurrent.Text, txtNew.Text))
        {
            lblInfo.Text = "Your password has been changed.";
        }
        else
        {
            lblInfo.Text = "Incorrect password !";
        }
    }

    protected void btnHome_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/Members/Stock.aspx");
    }
 
    protected void btnHelp_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/Members/Help.aspx");
    }
}